package com.vogue.supplymall.admin.business.controller;

import com.vogue.supplymall.admin.business.domain.biz.AdminHomePageBiz;
import com.vogue.supplymall.common.domain.dto.ControllerResultInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * The type Home page controller.
 *
 * @aouthor: zhangliang
 * @date: Create in 2017-12-21
 */
@RestController
public class AdminHomePageController extends BaseController {
    /**
     * The constant log.
     */
    public static final Logger LOGGER_ADMINHOMEPAGECONTROLLER = LoggerFactory.getLogger(AdminHomePageController.class);

    @Resource
    private AdminHomePageBiz adminHomePageBiz;

    /**
     * Hone page info response entity.
     * 首页信息
     *
     * @param appver the appver
     * @return the response entity
     */
    @RequestMapping(value = "/is/{appver}/admin/business/homepage", method = RequestMethod.POST)
    public ResponseEntity<Object> homePageInfo(@PathVariable("appver") String appver) {
        LOGGER_ADMINHOMEPAGECONTROLLER.info("admin homepage start >>>>>> ");
        Map<String, Object> data = new HashMap();
        Long validShop = adminHomePageBiz.countValidShop();
        Long validOrgan = adminHomePageBiz.countValidOrgan();
        data.put("validShop", validShop);
        data.put("validOrgan", validOrgan);
        ControllerResultInfo resultInfo = new ControllerResultInfo();
        resultInfo.setResult(true);
        resultInfo.setData(data);
        LOGGER_ADMINHOMEPAGECONTROLLER.info(" <<<<<< admin homepage end");
        return new ResponseEntity<>(resultInfo, HttpStatus.OK);
    }
}
